from filesplit.split import Split
from urllib3 import PoolManager
import shutil
import ssl
import urllib3

# split = Split(r'./multiprocess/sci-hub-doi-2022-02-12_1_1.txt', r'./multiprocess')
# split.bylinecount(linecount=10000)

# print('sci-hub-doi-2022-02-12_1_1_1'.split("_")[-1].split(".")[0])

ssl._create_default_https_context = ssl._create_unverified_context
tunnel = "a901.kdltps.com:15818"
username = "t19744135387372"
password = "gx1874ki"

proxies = {
    "http": "http://%(user)s:%(pwd)s@%(proxy)s/"
    % {"user": username, "pwd": password, "proxy": tunnel},
    "https": "http://%(user)s:%(pwd)s@%(proxy)s/"
    % {"user": username, "pwd": password, "proxy": tunnel},
}

url = 'https://sci-hub.st/tree/89/f9/89f9a92b89972e4c213e0ed9c24ac98a.pdf?download=true'
http = urllib3.ProxyManager(proxies)

with http.request('GET', url, preload_content=False) as res, open(
    'test.pdf', 'wb'
) as out:
    shutil.copyfileobj(res, out)
